def call(Map params = [:]) {
    // 默认参数
    def deploy_host   = params.get('deploy_host', '')
    def artifact   = params.get('artifact', '')
    def deploy_app   = params.get('deploy_app', '')
    def tags  = params.get('tags', '')

    if (!deploy_host) {
        error "Missing required param: deploy_host"
    }
    if(!artifact){
        error "Missing required param: artifact"
    }
    if(!deploy_app){
        error "Missing required param: deploy_app"
    }
    if (!tags) {
        error "Missing required param: tags"
    }
    dir('infra-playbook') {
        // git branch: branch, url: gitUrl, credentialsId: credId
        git branch: "master", url: "https://gitee.com/LingJianCode/jenkins-shared-lib.git"

        def cmd = """
            ansible-playbook ansible_role_playbook/deploy.yml \
              --extra-vars "deploy_host=${deploy_host} artifact=${artifact} deploy_app=${deploy_app}" \
              --tags "${tags}"
        """.stripIndent().trim()

        echo "Running: ${cmd}"
        sh(cmd)
    }
}
